home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
DB_CLIPP
/
2510.ZIP
/
TRSOURCE.EXE
/
BLANK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-22
|
3KB
|
93 lines
/*********
*
* BLANK.C
*
* by Tom Rettig
* modified by Leonard Zerman
*
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
* Syntax: BLANK( <exp> )
* Return: Empty value of parameter passed:
* TYPE RETURN NOTE
* ---- --------------- ----------------------------------
* L .F. logical type
* N 0.00 numeric type
* D ' / / ' date type
* C "..." len(<exp>) blank spaces
* C " : : " 8 byte, 6 digit time string type
* C " - " 11 byte, 10 digit zip code type
* C "( ) - " 13 byte, 10 digit telephone type
* C " - - " 11 byte, 9 digit social security number
* Unchanged <exp> if out of memory.
*********/
#include "trlib.h"
TRTYPE blank()
{
static char *blanks[] = { "00000000", /* date string makes ' / / ' */
" : : ", /* time */
" - ", /* zip */
"( ) - ", /* phone */
" - - " /* social security */
};
static char funcname[] = { "blank" };
char *instr, *ret;
int len, i;
if ( PCOUNT == 1 )
{
if ( ISLOG(1) )
_retl( FALSE );
else
if ( ISNUM(1) )
_retnd( 0.0 );
else
if ( ISDATE(1) )
_retds( blanks[0] );
else
if ( ISCHAR(1) )
{
instr = _parc(1);
/* _tr_strcmp() returns NULL if equal */
if ( VALIDTIME(instr) || !( _tr_strcmp(instr,blanks[1]) ) )
_retc( blanks[1] );
else
if ( ( VALIDZIP1(instr) && VALIDZIP2(instr) ) ||
!( _tr_strcmp(instr,blanks[2]) ) )
_retc( blanks[2] );
else
if ( ( VALIDPHON1(instr) && VALIDPHON2(instr) && VALIDPHON3(instr) ) ||
!( _tr_strcmp(instr,blanks[3]) ) )
_retc( blanks[3] );
else
if ( ( VALIDSS1(instr) && VALIDSS2(instr) ) ||
!( _tr_strcmp(instr,blanks[4]) ) )
_retc( blanks[4] );
else
{
/* character string without defined format */
len = _tr_strlen(instr);
ret = _tr_allocmem( (unsigned)(len+1));
if ( ret ) /* this branch must be last */
{
for ( i=0; i<len; i++ )
ret[i] = SPACEC;
ret[i] = NULLC;
_retc( ret );
_tr_freemem( ret,(unsigned)(len+1));
}
else
_retc( _tr_errmsgs(funcname,E_ALLOC) );
}
}
else
_retc( _tr_errmsgs(funcname,E_SYNTAX) );
}
else
_retc( _tr_errmsgs(funcname,E_SYNTAX) );
}
/* eof */